#!/bin/bash

# SSL Read 监听器演示脚本

echo "=== SSL Read 监听器演示 ==="
echo ""

# 检查程序是否存在
if [ ! -f "./ssl_monitor" ]; then
    echo "错误: 未找到 ssl_monitor 程序"
    echo "请先运行: ./build.sh"
    exit 1
fi

if [ ! -f "./test_ssl" ]; then
    echo "错误: 未找到 test_ssl 程序"
    echo "请先运行: ./build.sh"
    exit 1
fi

echo "1. 启动 SSL 监听器..."
echo "   在后台运行: sudo ./ssl_monitor"
echo ""

# 启动监听器
sudo ./ssl_monitor &
MONITOR_PID=$!

# 等待监听器启动
sleep 2

echo "2. 生成 SSL 流量..."
echo "   运行测试程序..."
echo ""

# 运行测试程序
./test_ssl

echo ""
echo "3. 停止监听器..."
echo "   按 Ctrl+C 停止监听器"
echo ""

# 等待用户输入
read -p "按回车键停止监听器..."

# 停止监听器
kill $MONITOR_PID 2>/dev/null || true

echo "演示完成" 